import * as types from '../mutation-types'

const defaultFilter={
  transFlag:'',//E支出 D-收入 空是所有
  transTypeId:'',// 交易明细类型 http://wiki.uletm.com/pages/viewpage.action?pageId=27564258
  beginTime:"", //开始时间
  endTime:''   //结束时间
}
const state = {
     tipShow:false,
     baseData:{},
     filtData:defaultFilter,
     defaultFilter:defaultFilter,
     showTab:{show:false,top:100,date:''},//
     showDateBox:false,//控制筛选日期的弹框出现 false关 true开
     showDateType:0  //0显示21017年10月10日 1显示2017年10月
}
const getters = {
  tipShow: state => state.tipShow,
  baseData:state=>state.baseData,
  status:state=>state.status,
  filtData:state=>state.filtData,
  defaultFilter:state=>state.defaultFilter,
  showTab:state=>state.showTab,
  showDateBox:state=>state.showDateBox,
  showDateType:state=>state.showDateType
}

const actions = {
  setBaseDate({ commit, state }, payload) {
    commit(types.BASE_DATA, payload);
  },
  setFilter({commit,state},payload){
    commit(types.SEARCH_FILTER,payload)
  }
}

const mutations = {
  [types.BASE_DATA](state, payload) {
    state.baseData=payload
  },
  [types.SEARCH_FILTER](state, payload) {
    if(payload&&payload.type){
      if(payload.type=="merge"){
        state.filtData={...state.filtData,...payload.data}
      }
    }else{
      state.filtData={...state.defaultFilter,...payload}
    }
  },
}
export default { state, getters, actions, mutations }